# coding=utf-8

from web import form

import models
from controllers.admin.partners.models import get_all_partner_names

# 蜘蛛表单
spider_form = form.Form(
            # 蜘蛛名
            form.Textbox('name'
                , description = '名称'
                , required = 'required'
                , class_ = 'txt'
                , tabindex = 1),
            # 合作商家
            form.Dropdown('partner_id'
                , get_all_partner_names()
                , description = '商家'
                , required = 'required'
                , class_ = 'txt'
                , tabindex = 2),
            # 提交
            form.Button('submit'
                , html = u'添加蜘蛛'
                , class_ = 'btn'
                , tabindex = 3),
        )

# 酒店抓取入口url
hotel_setting_form = form.Form(
            # 所属蜘蛛
            form.Dropdown('spider_id'
                , models.Spider.get_all_for_dropdown()
                , description = '蜘蛛'
                , required = 'required'
                , message = '请选择蜘蛛；'
                , class_ = 'txt'
                , tabindex = 1),
            # 目的地
            form.Hidden('dest_id'),
            # 酒店星级
            form.Dropdown('stars'
                , [(0, ''), (5, '五星/豪华'),(4, '四星/高档'),(3, '三星/舒适'),(2, '经济/客栈'),]
                , description = '酒店星级'
                , class_ = 'txt'
                , tabindex = 3),
            # 抓取url的正则表达式
            form.Textbox('url_regex'
                , description = 'URL Regex'
                , required = 'required'
                , message = '请输入 URL Regex；'
                , class_ = 'txt'
                , tabindex = 4),
            # 提交
            form.Button('submit'
                , html = u'添加酒店新规则'
                , class_ = 'btn'
                , tabindex = 5),
        )
